def is_abundant(num: int):
    sum_of_num = 1
    for i in range(2, int(pow(num, 0.5)) + 1):
        if num % i == 0:
            sum_of_num += (i + (num // i if num // i != i else 0))
    return sum_of_num > num


if __name__ == '__main__':
    res = ((1 + 28123) * 28123) // 2
    abundants = [12]
    for i in range(13, 28124 - 12 + 1):
        if is_abundant(i):
            abundants.append(i)
    reduce_nums = []
    for i in range(len(abundants)):
        for j in range(i, len(abundants)):
            t = abundants[i] + abundants[j]
            if t > 28123:
                break
            else:
                reduce_nums.append(t)
    print(res - sum(set(reduce_nums)))
